package debug_UI_Testing;

import java.awt.Component;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.junit.Before;
import org.junit.Test;
import org.uispec4j.*;
import org.uispec4j.finder.ComponentMatcher;
import org.uispec4j.interception.*;
import org.uispec4j.utils.UIComponentAnalyzer;
import UI_Testing.MyComponentFinder;
import blackjack.MyMath;
import debug.black;


/* TESTS SUMMARY
 * TEST V01: Player hit "start"-> 2 cards in the "card Set" are displayed [Arco 1]
 *   	TEST V01.1: cards are {2,3}
 *  	TEST V01.2: cards are {4,5}
 *  	TEST V01.3: cards are {6,7}
 *  	TEST V01.4: cards are {8,9}
 *  	TEST V01.5: cards are {10,J}
 *    	TEST V01.6: cards are {Q,K}
 *    	TEST V01.7: One of the card is 'A' {A,K}
 *  
 *  TEST V02: Player press "hit" before pressing start -> an error notification appear [Arco 2]
 *  TEST V03: Player press "stand" before pressing start -> an error notification appear [Arco 3]
 *  
 *  TEST V04:[after "start" | player busted] Player press "hit" 	[Arco 4]
 *  		 -> a textual notification is shown and Dealer's Game Point is incremented by 1
 *  TEST V05:[after "start" | player not busted]  Player press "hit" [Arco 5]
 *  		 -> the new card is added to ones already displayed
 *  
 *  TEST V06: [after "start" & "stand"| Player score is '4' | dealer hits until its score >= 17 ] 
 *  			 -> Dealer's cards are in "Card Set"
 * 		TEST V06.1: cards are {2,3,4,5,6}
 *  	TEST V06.2: cards are {7,8,9}
 *  	TEST V06.3: cards are {A,10}
 *  	TEST V06.4: cards are {10,J}
 *    	TEST V06.5: cards are {Q,K}
 *  
 *  TEST V07: [after "start"] Player press "hit" and scores "Blackjack"
 *  		 -> a "BlackJack" textual notification is shown and Player Game Point is incremented by 1 [Arco 7]
 *  TEST V08: Player Win the Game [not "Blackjack"]
 *  		 -> Player Game Point is incremented by 1, a "Win" textual notification is shown [Arco 8]
 *  TEST V09: Player Lose the game
 *  		 -> Dealer Game Point is incremented by 1, a "Lose" textual notification is shown [Arco 6]
 *  TEST V10: Player and the Dealer got the same score (push)
 *  		 -> a textual notification is shown				[Arco 9]
 *  TEST V11: Player press "hit" and scores "Blackjack"
 *  		 -> a "BlackJack" textual notification is shown and Player Game Point is incremented by 1 [Arco 10]
 *  TEST V12: [after "start" | cards received are {2,3} | card to be received are {4,5}]
 *  		 ->  Player press "start" [Arco 11]
 *  TEST V13: [after "start" | cards received are {2,3} | card to be received are {4,5}]
 *	  		 ->  Player press "start" [Arco 11]
 *	TEST V14: [after "start" | Player score is '4' ] Player play hit until he bust.
 *  			 -> Player's cards are in "Card Set"
 * 		TEST V014.1: cards are {2,2,2,3,4,5,6}
 *  	TEST V014.2: cards are {2,2,7,8,9}
 *  	TEST V014.3: cards are {2,2,10,J}
 *    	TEST V014.4: cards are {2,2,Q,K}
 *      TEST V014.5: cards are {2,2,A}
 *
 */


public class UI_test extends UISpecTestCase{

	
	private Window win;
	private JTextArea area;
	private JTextArea area_score;
	private JTextField field;

	@Before
	public void setUp()  {
		

		//Inizializzazione per tutte le classi di un Adattatore che ha il cui ruolo di realizzare l'adattamento tra la suite di test e l'applicazione
	    setAdapter(new MainClassAdapter(black.class, new String[0]));
	    //setAdapter(new MainClassAdapter(Starter.class, new String[0]));

	    win = getMainWindow();
	    Class[] swingClasses = UIComponentAnalyzer.getSwingClasses(TextBox.class) ;
	    MyComponentFinder f= new MyComponentFinder(win.getAwtContainer());
		Component[] comps= f.findComponents(ComponentMatcher.ALL,swingClasses) ;
		field=(JTextField) comps[0];
		area_score=(JTextArea) comps[1];
		area=(JTextArea) comps[2];
		
	}
	

	
	/** 
	 * TEST V01.1: Player hit "start"-> 2 cards are displayed | cards are {2,3}
	 */
	@Test
	public void test1_1() {
		double[] carte = {2,3};
		
		MyMath.set_randList(carte);
		win.getButton("start").click();
				
		assertEquals("Player\n 2 3", area.getText());
	}
	

	
	/** 
	 * TEST V01.2: Player hit "start"-> 2 cards are displayed| cards are {4,5}
	 */
	@Test
	public void test1_2() {
		double[] carte = {4,5};
		
		MyMath.set_randList(carte);
		win.getButton("start").click();
		
		assertEquals("Player\n 4 5", area.getText());
	}
	

	
	/** 
	 * TEST V01.3: Player hit "start"-> 2 cards are displayed | cards are {6,7}
	 */
	@Test
	public void test1_3() {
		double[] carte = {6,7};
		
		MyMath.set_randList(carte);
		win.getButton("start").click();
		
		assertEquals("Player\n 6 7", area.getText());
	}
	
	

	
	/** 
	 * TEST V01.4: Player hit "start"-> 2 cards are displayed | cards are {8,9}
	 */
	@Test
	public void test1_4() {
		double[] carte = {8,9};
		
		MyMath.set_randList(carte);
		win.getButton("start").click();
		
		assertEquals("Player\n 8 9", area.getText());
	}
	

	
	/** 
	 * TEST V01.1: Player hit "start"-> 2 cards are displayed | cards are {10,J}
	 */
	@Test
	public void test1_5() {
		double[] carte = {10,11};
		
		MyMath.set_randList(carte);
		win.getButton("start").click();
		
		assertEquals("Player\n 10 J", area.getText());
	}
	

	
	/** 
	 * TEST V01.6: Player hit "start"-> 2 cards are displayed | cards are {Q,K}
	 */
	@Test
	public void test1_6() {
		double[] carte = {12,13};
		
		MyMath.set_randList(carte);
		win.getButton("start").click();
		
		assertEquals("Player\n Q K", area.getText());
	}
	
	

	
	/** 
	* TEST V01.7: Player hit "start"-> 2 cards are displayed | cards are {A,K} 
	*/
	@Test
	public void test1_7() {
		double[] carte = {1,13};
		
		MyMath.set_randList(carte);
		win.getButton("start").click();
		
		assertEquals("Player\n A K", area.getText());		// Cards in set
		
	}
	
	 /*
	  * TEST V02: Player press "hit" before pressing start -> an error notification appear
	  */
	 @Test
	public void test2() {

		 WindowInterceptor.init(
			new Trigger() {
			    public void run() {
			    	win.getButton("hit").click();
			    }
		 	}
        ).process(
            BasicHandler.init()
			.assertContainsText("push start!")
			.triggerButtonClick("OK")
		)
		.run();
	 }
	 
	 
	 
	 /*
	  *   TEST V03: Player press "stand" before pressing start -> an error notification appear
	  */
	 @Test
	public void test3() {	
		WindowInterceptor.init(
			win.getButton("stand").triggerClick())
			.process(BasicHandler.init()
			.assertContainsText("push start!")
			.triggerButtonClick("OK")
		).run();
		
	}
	 
	 /*  
	 *  TEST V04:[after "start" | player busted] Player press "hit" 
	 *  		 ->  a textual notification is shown and Dealer's Game Point is incremented by 1
	 */  
	@Test
	public void test4() {
		double[] carte = {10,10,13};
		MyMath.set_randList(carte);
		
		int pStart, pEnd,dStart;
		int pStartGamePoint=-1,dStartGamePoint=-1;
			
		//Calculate Starting GamePoint
		String startScores = area_score.getText();
			
		pStart = startScores.indexOf(":")+ 2;
		pEnd = startScores.indexOf("\n");
		dStart = startScores.indexOf("Cpu: ")+5;
			
		try{
			pStartGamePoint = Integer.parseInt(startScores.substring(pStart, pEnd));
			dStartGamePoint = Integer.parseInt(startScores.substring(dStart));
		}catch(Exception e){
			pStartGamePoint = 0;
			dStartGamePoint = 0;
		}

		//Execute action
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("hit").click();

		//Calculate Ending GamePoint
		String endScores = area_score.getText();
			
		pStart = endScores.indexOf(":")+ 2;
		pEnd = endScores.indexOf("\n");
		dStart = endScores.indexOf("Cpu: ")+5;
		
		int pEndGamePoint = Integer.parseInt(endScores.substring(pStart, pEnd));
		int dEndGamePoint = Integer.parseInt(endScores.substring(dStart));
		
		assertEquals("Busted!", field.getText());			// Busted Textual Notification
		assertEquals(pStartGamePoint,pEndGamePoint);		//Player Game Point is not incremented
		assertEquals(dStartGamePoint+1,dEndGamePoint);		//Dealer Game Point is incremented
	}
	 
	 
	 /*  TEST V05:[after "start" | player not busted]  Player press "hit" 
	 *  		 ->  the new card is added to ones already displayed
	 */  
	@Test
	public void test5() {
		double[] carte = {5,6,7};
		
			
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("hit").click();
			
		assertEquals("", field.getText());		//Player not busted
		
		
	}

	/*TEST V06.1: [after "start" & "stand"| Player score is '4' | dealer hits until its score >= 17 ] 
	 *  			 -> Dealer's cards are {2,3,4,5,6}
	*/  
	@Test
	public void test6_1() {
		double[] carte = {2,2,2,3,4,5,6};
			
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("stand").click();
		String cards = area.getText();

		try{
			String dealerCards = cards.substring(cards.indexOf("Cpu"));
			assertEquals("Cpu\n 2 3 4 5 6",dealerCards);
		}catch(Exception e){
			fail();
		}
	}	
		
		
	/*
	 * TEST V06.2: [after "start" & "stand"| Player score is '4' | dealer hits until its score >= 17 ] 
	 *  			 -> Dealer's cards are {7,8,9}
	*/  
	public void test6_2() {
		double[] carte = {2,2,7,8,9};
		
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("stand").click();
		String cards = area.getText();

		try{
			String dealerCards = cards.substring(cards.indexOf("Cpu"));
			assertEquals("Cpu\n 7 8 9",dealerCards);
		}catch(Exception e){
			fail();
		}
	}	
		
		
	/*TEST V06.3: [after "start" & "stand"| Player score is '4' | dealer hits until its score >= 17 ] 
	 *  			 -> Dealer's cards are {A,10}
	*/  
				
	public void test6_3() {
		double[] carte = {2,2,1,10};
			
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("stand").click();
		String cards = area.getText();
		
		try{
			String dealerCards = cards.substring(cards.indexOf("Cpu"));
			assertEquals("Cpu\n A 10",dealerCards);
		}catch(Exception e){
			fail();
		}
	}	
		
	/*TEST V06.4: [after "start" & "stand"| Player score is '4' | dealer hits until its score >= 17 ] 
	 *  			 -> Dealer's cards are {10,J}
	*/  
	public void test6_4() {
		double[] carte = {2,2,10,11};
			
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("stand").click();
		String cards = area.getText();
		
		try{
			String dealerCards = cards.substring(cards.indexOf("Cpu"));
			assertEquals("Cpu\n 10 J",dealerCards);
		}catch(Exception e){
			fail();
		}
	}	
		
		
	/*TEST V06.5: [after "start" & "stand"| Player score is '4' | dealer hits until its score >= 17 ] 
	 *  			 -> Dealer's cards are {Q,K}
	*/  
				
		
	public void test6_5() {
		double[] carte = {2,2,12,13};
			
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("stand").click();
		String cards = area.getText();
		 
		try{
			String dealerCards = cards.substring(cards.indexOf("Cpu"));
			assertEquals("Cpu\n Q K",dealerCards);
		}catch(Exception e){
			fail();
		}
	}
	
	/* 
	*  TEST V07: Player press "hit" and scores "Blackjack" 
	*  -> a textual notification is shown and Player Game Point is incremented by 1
	*/
	@Test
	public void test7() {
		double[] carte = {1,5,5};
		int pStart, pEnd,dStart;
		int pStartGamePoint=-1,dStartGamePoint=-1;
			
		//Calculate Starting GamePoint
		String startScores = area_score.getText();
			
		pStart = startScores.indexOf(":")+ 2;
		pEnd = startScores.indexOf("\n");
		dStart = startScores.indexOf("Cpu: ")+5;
			
		try{
			pStartGamePoint = Integer.parseInt(startScores.substring(pStart, pEnd));
			dStartGamePoint = Integer.parseInt(startScores.substring(dStart));
		}catch(Exception e){
			pStartGamePoint = 0;
			dStartGamePoint = 0;
		}

		//Execute action
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("hit").click();

		//Calculate Ending GamePoint
		String endScores = area_score.getText();
			
		pStart = endScores.indexOf(":")+ 2;
		pEnd = endScores.indexOf("\n");
		dStart = endScores.indexOf("Cpu: ")+5;
		
		int pEndGamePoint = Integer.parseInt(endScores.substring(pStart, pEnd));
		int dEndGamePoint = Integer.parseInt(endScores.substring(dStart));

		assertEquals(dStartGamePoint,dEndGamePoint);		//Dealer Game Point is not incremented
		assertEquals(pStartGamePoint+1,pEndGamePoint);		//Player Game Point is incremented
		assertEquals("BlackJack!", field.getText());		//BlackJack Textual Notification
				
	}
		
	/* 
	 *  TEST V08: Player Win the Game [not "Blackjack"] 
	 *  -> Player Game Point is incremented by 1, a textual notification is shown
	 */
	public void test8() {
		double[] carte = {11,10,9,9,11};
		int pStart, pEnd,dStart;
		int pStartGamePoint=-1,dStartGamePoint=-1;
			
		//Calculate Starting GamePoint
		String startScores = area_score.getText();
			
		pStart = startScores.indexOf(":")+ 2;
		pEnd = startScores.indexOf("\n");
		dStart = startScores.indexOf("Cpu: ")+5;
			
		try{
			pStartGamePoint = Integer.parseInt(startScores.substring(pStart, pEnd));
			dStartGamePoint = Integer.parseInt(startScores.substring(dStart));
		}catch(Exception e){
			pStartGamePoint = 0;
			dStartGamePoint = 0;
		}

		//Execute action
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("stand").click();

		//Calculate Ending GamePoint
		String endScores = area_score.getText();
			
		pStart = endScores.indexOf(":")+ 2;
		pEnd = endScores.indexOf("\n");
		dStart = endScores.indexOf("Cpu: ")+5;
		
		int pEndGamePoint = Integer.parseInt(endScores.substring(pStart, pEnd));
		int dEndGamePoint = Integer.parseInt(endScores.substring(dStart));
		
		assertEquals(dStartGamePoint,dEndGamePoint);		//Dealer Game Point is not incremented
		assertEquals(pStartGamePoint+1,pEndGamePoint);		//Player Game Point is incremented
		assertEquals("Win!", field.getText());				// Player Win
	}
	
	/*
	 * TEST V09: Player Lose the game 
	 * -> Dealer Game Point is incremented by 1, a textual notification is shown
	 */  
	@Test
	public void test9() {
		double[] carte = {2,5,13};
		
		int pStart, pEnd,dStart;
		int pStartGamePoint=-1,dStartGamePoint=-1;
			
		//Calculate Starting GamePoint
		String startScores = area_score.getText();
			
		pStart = startScores.indexOf(":")+ 2;
		pEnd = startScores.indexOf("\n");
		dStart = startScores.indexOf("Cpu: ")+5;
			
		try{
			pStartGamePoint = Integer.parseInt(startScores.substring(pStart, pEnd));
			dStartGamePoint = Integer.parseInt(startScores.substring(dStart));
		}catch(Exception e){
			pStartGamePoint = 0;
			dStartGamePoint = 0;
		}

		//Execute action
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("stand").click();

		//Calculate Ending GamePoint
		String endScores = area_score.getText();
			
		pStart = endScores.indexOf(":")+ 2;
		pEnd = endScores.indexOf("\n");
		dStart = endScores.indexOf("Cpu: ")+5;
		int pEndGamePoint, dEndGamePoint;
		try{
			pEndGamePoint = Integer.parseInt(endScores.substring(pStart, pEnd));
			dEndGamePoint = Integer.parseInt(endScores.substring(dStart));
		}catch(Exception e){
			pEndGamePoint = 0;
			dEndGamePoint = 0;
		}
		
		assertEquals(pStartGamePoint,pEndGamePoint);		//Player Game Point is not incremented
		assertEquals(dStartGamePoint+1,dEndGamePoint);		//Dealer Game Point is incremented
		assertEquals("Lose!", field.getText());				//Lose Textual Notification
	}

	/*
	 *  TEST V10: Player and the Dealer got the same score (push)-> a textual notification is shown
	 */  
	@Test
	public void test10() {
		double[] carte = {10,11,12,13};
		int pStart, pEnd,dStart;
		int pStartGamePoint=-1,dStartGamePoint=-1;
		
		//Calculate Starting GamePoint
		String startScores = area_score.getText();
		
		pStart = startScores.indexOf(":")+ 2;
		pEnd = startScores.indexOf("\n");
		dStart = startScores.indexOf("Cpu: ")+5;
		
		try{
			pStartGamePoint = Integer.parseInt(startScores.substring(pStart, pEnd));
			dStartGamePoint = Integer.parseInt(startScores.substring(dStart));
		}catch(Exception e){
			pStartGamePoint = 0;
			dStartGamePoint = 0;
		}
		
		//Execute Action
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("stand").click();

		//Calculate Ending GamePoint
		String endScores = area_score.getText();
		
		pStart = endScores.indexOf(":")+ 2;
		pEnd = endScores.indexOf("\n");
		dStart = endScores.indexOf("Cpu: ")+5;
		
		int pEndGamePoint = Integer.parseInt(endScores.substring(pStart, pEnd));
		int dEndGamePoint = Integer.parseInt(endScores.substring(dStart));
		
		assertEquals("Push!", field.getText());				// Push notification
		assertEquals(dStartGamePoint,dEndGamePoint);		//Dealer Game Point is not incremented
		assertEquals(pStartGamePoint,pEndGamePoint);		//Player Game Point is not incremented
	}
	/* 
	*  TEST V11: Player press start and scores "Blackjack"
	*   -> a textual notification is shown and Player Game Point is incremented by 1
	*/
	@Test
	public void test11() {
		double[] carte = {1,13};
		int pStart, pEnd,dStart;
		int pStartGamePoint=-1,dStartGamePoint=-1;
			
		//Calculate Starting GamePoint
		String startScores = area_score.getText();
			
		pStart = startScores.indexOf(":")+ 2;
		pEnd = startScores.indexOf("\n");
		dStart = startScores.indexOf("Cpu: ")+5;
			
		try{
			pStartGamePoint = Integer.parseInt(startScores.substring(pStart, pEnd));
			dStartGamePoint = Integer.parseInt(startScores.substring(dStart));
		}catch(Exception e){
			pStartGamePoint = 0;
			dStartGamePoint = 0;
		}

		//Execute action
		MyMath.set_randList(carte);
		win.getButton("start").click();
		
		//Calculate Ending GamePoint
		String endScores = area_score.getText();
			
		pStart = endScores.indexOf(":")+ 2;
		pEnd = endScores.indexOf("\n");
		dStart = endScores.indexOf("Cpu: ")+5;
		
		int pEndGamePoint, dEndGamePoint;
		try{
			pEndGamePoint = Integer.parseInt(endScores.substring(pStart, pEnd));
			dEndGamePoint = Integer.parseInt(endScores.substring(dStart));
		}catch(Exception e){
			pEndGamePoint = 0;
			dEndGamePoint = 0;
		}
		
		assertEquals(dStartGamePoint,dEndGamePoint);		//Dealer Game Point is not incremented
		assertEquals(pStartGamePoint+1,pEndGamePoint);		//Player Game Point is incremented
		assertEquals("21 Vittoria Grande Baldoria!", field.getText());		//BlackJack Textual Notification
				
	}
	

	
	/** 
	 * TEST V12: [after "start" | cards received are {2,3} | card to be received are {4,5}]
	 *  		 ->  Player press "start" [Arco 11]
	 */
	@Test
	public void test12() {
		double[] carte = {2,3,4,5};
		
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("start").click();
		
		assertEquals("Player\n 4 5", area.getText());
	}
	
	/* 
	*  TEST V13: [after "start"] Player press start and scores "Blackjack"
	*   		-> a textual notification is shown and Player Game Point is incremented by 1
	*/  
	
	@Test
	public void test13() {
		double[] carte = {5,5,1,13};
		int pStart, pEnd,dStart;
		int pStartGamePoint=-1,dStartGamePoint=-1;
			
		//Calculate Starting GamePoint
		String startScores = area_score.getText();
			
		pStart = startScores.indexOf(":")+ 2;
		pEnd = startScores.indexOf("\n");
		dStart = startScores.indexOf("Cpu: ")+5;
			
		try{
			pStartGamePoint = Integer.parseInt(startScores.substring(pStart, pEnd));
			dStartGamePoint = Integer.parseInt(startScores.substring(dStart));
		}catch(Exception e){
			pStartGamePoint = 0;
			dStartGamePoint = 0;
		}

		//Execute action
		MyMath.set_randList(carte);
		win.getButton("start").click();
		win.getButton("start").click();
		
		//Calculate Ending GamePoint
		String endScores = area_score.getText();
			
		pStart = endScores.indexOf(":")+ 2;
		pEnd = endScores.indexOf("\n");
		dStart = endScores.indexOf("Cpu: ")+5;
		
		int pEndGamePoint, dEndGamePoint;
		try{
			pEndGamePoint = Integer.parseInt(endScores.substring(pStart, pEnd));
			dEndGamePoint = Integer.parseInt(endScores.substring(dStart));
		}catch(Exception e){
			pEndGamePoint = 0;
			dEndGamePoint = 0;
		}
		
		assertEquals(dStartGamePoint,dEndGamePoint);		//Dealer Game Point is not incremented
		assertEquals(pStartGamePoint+1,pEndGamePoint);		//Player Game Point is incremented
		assertEquals("21 Vittoria Grande Baldoria!", field.getText());		//BlackJack Textual Notification
				
	}
	
	/* TEST V14.1: [after "start" | Player score is '4' ] Player play hit until he bust.
	 *  			 -> Player's cards are in {2,2,2,3,4,5,6}
	*/
	@Test
	public void test14_1() {
		double[] carte = {2,2,2,3,4,5,6};
		
			
		MyMath.set_randList(carte);
		win.getButton("start").click();
		String oldcards = area.getText();
		win.getButton("hit").click();
		win.getButton("hit").click();
		win.getButton("hit").click();
		win.getButton("hit").click();
		win.getButton("hit").click();
			
		assertEquals(oldcards+" 2 3 4 5 6", area.getText());
	}
	/* TEST V14.2: [after "start" | Player score is '4' ] Player play hit until he bust.
	 *  			 -> Player's cards are in {2,2,7,8,9}
	*/
	@Test
	public void test14_2() {
		double[] carte = {2,2,7,8,9};
		
			
		MyMath.set_randList(carte);
		win.getButton("start").click();
		String oldcards = area.getText();
		win.getButton("hit").click();
		win.getButton("hit").click();
		win.getButton("hit").click();
			
		assertEquals(oldcards+" 7 8 9", area.getText());
	}
	
	/* TEST V14.3: [after "start" | Player score is '4' ] Player play hit until he bust.
	 *  			 -> Player's cards are in {2,2,10,J}
	*/
	@Test
	public void test14_3() {
		double[] carte = {2,2,10,11};
		
		MyMath.set_randList(carte);
		win.getButton("start").click();
		String oldcards = area.getText();
		win.getButton("hit").click();
		win.getButton("hit").click();
			
		assertEquals(oldcards+" 10 J", area.getText());
	}
	
	/* TEST V14.4: [after "start" | Player score is '4' ] Player play hit until he bust.
	 *  			 -> Player's cards are in {2,2,Q,K}
	*/
	
	@Test
	public void test14_4() {
		double[] carte = {2,2,12,13};
		
			
		MyMath.set_randList(carte);
		win.getButton("start").click();
		String oldcards = area.getText();
		win.getButton("hit").click();
		win.getButton("hit").click();
			
		assertEquals(oldcards+" Q K", area.getText());
	}
	
	/* TEST V14.4: [after "start" | Player score is '4' ] Player play hit until he bust.
	 *  			 -> Player's cards are in {2,2,A}
	*/
	
	@Test
	public void test14_5() {
		double[] carte = {2,2,1};
		
			
		MyMath.set_randList(carte);
		win.getButton("start").click();
		String oldcards = area.getText();
		win.getButton("hit").click();
			
		assertEquals(oldcards+" A", area.getText());
	}

}

